<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<c:set var="extLibs" value="validate"/>
<sys:header title="提醒消息管理 - ${message.isNewRecord ? '新增' : '编辑'}提醒消息" extLibs="${extLibs}"/>
<div class="portlet box ${boxStyleColor} autoHeight">
	<div class="portlet-title">
		<div class="caption"><i class="fa fa-coffee"></i>群发短信</div>
	</div>
	<div class="portlet-body form">
		<form:form id="inputForm" modelAttribute="send" action="${ctx}/msg/send/send" method="post" class="form-horizontal">
			<div class="form-body">
				<h4 class="form-section">基本信息</h4>
				<form:hidden path="id"/>
				<form:hidden path="mobile"/>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								发送内容：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<form:textarea path="content" htmlEscape="false" rows="4" maxlength="255" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								发送类型：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<input type="radio" name="isGroup" value="1" checked>组发
								<input type="radio" name="isGroup" value="2">自定义
							</div>
						</div>
					</div>
				</div>

				<div class="row groupType ">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4">选择发送组：</label>
							<div class="col-sm-8">
								<sys:listselect id="group" name="groupId" value="${send.groupId}" labelName="groupName" labelValue="${send.groupName}"
												title="群组" url="${ctx}/msg/msgNoteGroup/noteGroupSelect"   cssClass="form-control " />
							</div>
						</div>
					</div>
				</div>
				<div class="row customType" hidden>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4">选择发送人：</label>
							<div class="col-sm-8">
								<sys:listselect id="member" name="memberCode" value="${send.memberCode}" labelName="memberName" labelValue="${send.memberName}"
									title="会员" url="${ctx}/mdm/member/memberSelect" multiple="true"  cssClass="form-control " />
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="form-actions fluid">
				<div class="row">
					<div class="col-xs-12">
						<div class="col-sm-offset-2 col-sm-10">
							<shiro:hasPermission name="msg:send:edit">
								<button id="btnSubmit" type="submit" class="btn btn-primary"><i class="fa fa-check"></i> 发送</button>&nbsp;
							</shiro:hasPermission>
							<button id="btnCancel" type="button" class="btn default" onclick="closeCurrentTabPage('${param.parentTabPageId}')"><i class="fa fa-reply-all"></i> 关 闭</button>
						</div>
					</div>
				</div>
			</div>
		</form:form>
	</div>
</div>
<sys:footer extLibs="${extLibs}"/>
<script type="text/javascript">

	//会员选择回调
	function memberCallbackForMap(dataMap, v, h, f){
			var codes = [], names = [],mobiles=[];
		$.each(dataMap, function(key, value){
			codes.push(value.memberCode);
			names.push(value.memberName);
			mobiles.push(value.phone);
			
		});
		$('#memberCode').val(codes.join(','));
		$('#memberName').val(names.join(','));
		$('#mobile').val(mobiles.join(','));
	}

	function groupCallbackForMap(dataMap, v, h, f){
		var codes = [], names = [];
		$.each(dataMap, function(key, value){
			codes.push(value.groupid);
			names.push(value.groupName);
		});
		$('#groupid').val(codes.join(','));
		$('#groupName').val(names.join(','));
	}
	$("#inputForm").validate({
		submitHandler: function(form){
			ajaxSubmitForm($(form), function(data){
				showMessage(data.message);
				if(data.result == Global.TRUE){
					closeCurrentTabPage('${param.parentTabPageId}', function(contents, contentWindow){
						contentWindow.page();
					});
				}
			}, "json");
	    }
	});

	$(function(){
		$(":radio").click(function(){
			if($(this).val()=='1'){
				$(".groupType").show();
				$(".customType").hide();

			}else{
				$(".groupType").hide();
				$(".customType").show();
			}
		});
	});
</script>